package org.jeecg.modules.reserve.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.reserve.entity.SdxcReserve;
import org.jeecg.modules.reserve.entity.SdxcReservePlace;
import org.jeecg.modules.reserve.mapper.SdxcReserveMapper;
import org.jeecg.modules.reserve.mapper.SdxcReservePlaceMapper;
import org.jeecg.modules.reserve.service.ISdxcReserveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * @Description: sdxc_reserve
 * @Author: jeecg-boot
 * @Date:   2020-09-18
 * @Version: V1.0
 */
@Service
public class SdxcReserveServiceImpl extends ServiceImpl<SdxcReserveMapper, SdxcReserve> implements ISdxcReserveService {
   @Autowired
   private SdxcReserveMapper sdxcReserveMapper;
    @Autowired
    private SdxcReservePlaceMapper sdxcReservePlaceMapper;
    @Override
    public List<SdxcReserve> queryReserveListByUserId(String userId){

        QueryWrapper<SdxcReserve> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        List<SdxcReserve> list_sdxcreserve= sdxcReserveMapper.selectList(queryWrapper);


        for (int i = 0; i < list_sdxcreserve.size(); i++) {
            SdxcReserve sdxcReserve=list_sdxcreserve.get(i);
            String place=sdxcReserve.getPlaceId();
            SdxcReservePlace sdxcReservePlace=sdxcReservePlaceMapper.selectById(place);
            sdxcReserve.setPlaceName(sdxcReservePlace.getName());
        }
        return list_sdxcreserve;
    }
    @Override
    public void delete(String id){
        sdxcReserveMapper.deleteById(id);
        return;
    }
}
